#ifndef POPEYE_H
#define POPEYE_H

#include "Sprite.h"
#include "Platform.h"
#include "Stair.h"
#include "Step.h"
#include "PlatformHolder.h"
#include "FrameRangeAnimation.h"
#include "FrameRangeAnimator.h"
#include "MovingAnimation.h"
#include "MovingAnimator.h"
#include "TimerTickAnimator.h"
#include "FlashingAnimation.h"
#include "FlashingAnimator.h"

enum popeyeMode {
	normal,
	spinach,
	dead
};

class Popeye : public Sprite {
private:
	FrameRangeAnimation *walkAnimation, *punchAnimation;
	FrameRangeAnimator *walkAnimator, *punchAnimator;
	MovingAnimation *fallAnimation, *deathAnimation;
	MovingAnimator *fallAnimator, *deathAnimator;
	FlashingAnimation *flashAnimation;
	FlashingAnimator *flashAnimator;
	TickAnimation *tickAnimation;
	TimerTickAnimator *timerTick;
	bool isInvisible;
	bool isPunching;
	unsigned int life;
	int velocity;
	static enum popeyeMode Mode;
	static void Dummy(void *closure);
	static void SpinachModeCompleted(Animator *animator, void *closure);
	static void PunchCompleted(Animator*, void *closure);
	static void InvinsibilityEnded(Animator *, void *closure);
public:
	Popeye::Popeye(Dim _x, Dim _y, AnimationFilm* film,
		FrameRangeAnimation *_walkAnimation, FrameRangeAnimator *_walkAnimator,
		FrameRangeAnimation *_punchAnimation, FrameRangeAnimator *_punchAnimator,
		MovingAnimation *_fallAnimation, MovingAnimator *_fallAnimator, 
		MovingAnimation *_deathAnimation, MovingAnimator *_deathAnimator);
	~Popeye(void);
	//Horizontal movement
	void MoveHorizontal(int dx);
	void StopMoving(void);
	virtual void Move(int dx, int dy);
	void Fall(int x);
	void NotifyStartFalling(void);
	void NotifyStopFalling(void);
	//Vertical movement
	void MoveUp(void);
	void MoveDown(void);
	void Punch(void);
	bool Punches(void);
	void changeMode(void);
	enum popeyeMode getMode(void);
	void removeLife(void);
	void addLife(void);
	unsigned int getLives(void);
	bool isAbleToMove(void);
	bool falls(void);
	virtual void ResetToDefaultFilm();
	void SetWalkFilm();
	void SetPunchFilm();
	void SetVerticalClimbFilm();
	void SetDiagonalClimbUpFilm();
	void SetDiagonalClimbDownFilm();
	void SetDeathFilm(void);
	bool OnPlatform(void);
	virtual void CollisionAction(Sprite *s);
	void Die(void);
	static bool DeathCompleted(void);
	bool isDead();
	void PlayDeathAnimation();
	void GotHit();
	void setInvinsibility(bool _inv) { isInvisible = _inv; }; 
};

#endif
